IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'DeleteLogServicioByIdLote')
	BEGIN
		DROP  Procedure  DeleteLogServicioByIdLote
	END

GO

CREATE Procedure DeleteLogServicioByIdLote

	(
		@IdLote int,
		@IdEstado int = NULL
	)

AS

DELETE FROM LogServicio 
WHERE 
	CASE 
		WHEN @IdEstado IS NULL THEN 1
		WHEN IdEstado = @IdEstado THEN 1
		ELSE 0
	END = 1

GO

GRANT EXEC ON DeleteLogServicioByIdLote TO PUBLIC

GO


